﻿using System.ComponentModel.DataAnnotations;
using Dexter.Web.Mvc.Annotations;
using Dexter.Web.Mvc.ViewModel.Resources;

namespace Dexter.Web.Mvc.ViewModel.Backoffice.Binders {
	[PropertiesMustMatch ( "Password" , "ConfirmPassword" , ErrorMessageResourceType = typeof ( Errors ) , ErrorMessageResourceName = "FieldsMustMatch" )]
	[PropertiesMustMatch ( "Email" , "ConfirmEmail" , ErrorMessageResourceType = typeof ( Errors ) , ErrorMessageResourceName = "FieldsMustMatch" )]
	public class UserBinder {
		[Required ( ErrorMessageResourceType = typeof ( Errors ) , ErrorMessageResourceName = "RequiredField" )]
		public string Username { get; set; }

		[Required ( ErrorMessageResourceType = typeof ( Errors ) , ErrorMessageResourceName = "RequiredField" )]
		public string Password { get; set; }

		[Required ( ErrorMessageResourceType = typeof ( Errors ) , ErrorMessageResourceName = "RequiredField" )]
		public string ConfirmPassword { get; set; }

		[Required ( ErrorMessageResourceType = typeof ( Errors ) , ErrorMessageResourceName = "RequiredField" )]
		public string Email { get; set; }

		[Required ( ErrorMessageResourceType = typeof ( Errors ) , ErrorMessageResourceName = "RequiredField" )]
		public string ConfirmEmail { get; set; }

		public bool IsAdministrator { get; set; }
		public bool IsModerator { get; set; }
		public bool IsPoster { get; set; }

		public static UserBinder EmptyInstance ( ) {
			return new UserBinder {
				ConfirmEmail = string.Empty ,
				ConfirmPassword = string.Empty ,
				Email = string.Empty ,
				Password = string.Empty ,
				Username = string.Empty
			};
		}
	}
}